package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.goodscategory.GoodsCategoryBO;
import com.micro.modual.model.bo.goodscategory.GoodsCategoryStatusBO;
import com.micro.modual.model.dto.goodscategory.GoodsCategoryDetailDTO;
import com.micro.modual.model.dto.goodscategory.GoodsCategoryListDTO;
import com.micro.modual.model.tree.CategoryTreeDTO;
import com.micro.modual.service.GoodsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <h1>商品分类表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "商品分类管理",tags = "商品分类管理")
@RestController
@RequestMapping(value = "goodsCategory")
public class GoodsCategoryController {

    @Autowired
    private GoodsCategoryService goodsCategoryService;

    /**
     * <h2>查找商品分类表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<GoodsCategoryListDTO> {@link GoodsCategoryListDTO}s  商品分类表 列表返回对象
     */
    @ApiOperation(value = "查询商品分类表列表" ,notes = "查询商品分类表列表")
    @GetMapping(value = "/findGoodsCategoryList")
    public RespJsonPageData<GoodsCategoryListDTO> findGoodsCategoryList(@RequestParam  Map<String,Object> params){
        return goodsCategoryService.findGoodsCategoryPageList(params);
    }

    /**
     * <h2>根据主键编号查看商品分类表详情</h2>
     * @param id  商品分类表 主键编号
     * @return {@link GoodsCategoryDetailDTO}  商品分类表 详情
     */
    @ApiOperation(value = "查询商品分类表详情",notes = "根据主键编号，查询商品分类表详情")
    @GetMapping(value = "/findGoodsCategoryDetail/{id}")
    public RespJsonData<GoodsCategoryDetailDTO> findGoodsCategoryDetail(@PathVariable("id") Long id){
        return goodsCategoryService.findDetail(id,GoodsCategoryDetailDTO.class);
    }

    /**
     * <h2>新增商品分类表详情</h2>
     * @param goodsCategoryBO {@link GoodsCategoryBO} 商品分类表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增商品分类表",notes = "新增商品分类表")
    @PostMapping(value = "/addGoodsCategory")
    public RespJson addGoodsCategory(@RequestBody GoodsCategoryBO goodsCategoryBO){
        return goodsCategoryService.addGoodsCategory(goodsCategoryBO);
    }

    /**
     * <h2>修改商品分类表详情</h2>
     * @param goodsCategoryBO  {@link GoodsCategoryBO} 商品分类表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改商品分类表",notes = "修改商品分类表")
    @PostMapping(value = "/editGoodsCategory")
    public RespJson editGoodsCategory(@RequestBody GoodsCategoryBO goodsCategoryBO){
        return goodsCategoryService.editGoodsCategory(goodsCategoryBO);
    }

    /**
     * <h2>根据主键编号删除商品分类表信息</h2>
     * @param id  商品分类表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除商品分类表",notes = "根据地址ID，删除商品分类表")
    @PostMapping(value = "/deleteGoodsCategory/{id}")
    public RespJson deleteGoodsCategory(@PathVariable("id") Long id){
        return goodsCategoryService.deleteGoodsCategory(id);
    }

    /**
     * <h2>修改分类状态</h2>
     * @param goodsCategoryStatusBO {@link GoodsCategoryStatusBO} 修改角色状态请求对象
     * @return
     */
    @ApiOperation(value = "修改分类状态",notes = "修改分类状态")
    @PostMapping(value = "/modifyGoodsCategoryStatus")
    public RespJson modifyGoodsCategoryStatus(@RequestBody GoodsCategoryStatusBO goodsCategoryStatusBO){
        return goodsCategoryService.modifyGoodsCategoryStatus(goodsCategoryStatusBO);
    }

    /**
     * <h2>获取所有分类树信息</h2>
     * @return
     */
    @ApiOperation(value = "获取所有分类树信息",notes = "获取所有分类树信息")
    @GetMapping(value = "/findCategoryTree")
    public RespJsonData<List<CategoryTreeDTO>> findCategoryTree(){
        return goodsCategoryService.findCategoryTree();
    }

}

